<template>
  <el-dropdown placement="top">
    <div class="item">
      <div class="content">
        <span class="index">{{ index + 1 }}.</span>{{ content }}
      </div>
      <div class="options">
        <div class="option" v-for="option in options" :key="option.id">
          <b>{{ option.id }}.</b>{{ option.text }}
        </div>
      </div>
      <div class="desc" v-if="displayDesc">
        <div><b>正确答案：</b>{{ answer }}</div>
        <div><b>解析：</b>{{ desc }}</div>
      </div>
      <div class="opts">
        <div class="labels">
          <span>选择题</span>
          <span>{{ knowledge }}</span>
        </div>
        <el-button
          :class="selected ? 'btn-active' : 'btn'"
          color="#43b883"
          :dark="selected"
          :plain="!selected"
          >{{ selected ? '移出试卷' : '加入试卷' }}</el-button
        >
      </div>
    </div>
    <template #dropdown>
      <el-dropdown-menu class="tools">
        <el-dropdown-item command="a">换一题</el-dropdown-item>
        <el-dropdown-item command="b">上移</el-dropdown-item>
        <el-dropdown-item command="c">下移</el-dropdown-item>
        <el-dropdown-item command="a">手动编辑</el-dropdown-item>
        <el-dropdown-item command="b"
          ><el-text class="mx-1">AI润色</el-text
          ><el-icon color="#43b883" size="20" style="margin-left: 0.2rem"><MagicStick /></el-icon
        ></el-dropdown-item>
        <el-dropdown-item command="c"
          ><el-text class="mx-1" type="danger">删除</el-text></el-dropdown-item
        >
      </el-dropdown-menu>
    </template>
  </el-dropdown>
</template>

<script setup>
defineProps([
  'index',
  'id',
  'content',
  'options',
  'answer',
  'desc',
  'displayDesc',
  'knowledge',
  'selected'
])
// 下标，id，题干，选项，答案，解析，是否显示解析，知识点，是否选择
</script>

<style lang="scss" scoped>
.el-tooltip__trigger:focus-visible {
  outline: none !important;
}

.el-dropdown-menu {
  display: flex;
}

.item {
  margin-bottom: 1rem;
  position: relative;
  line-height: 1.8;

  .content {
    .index {
      padding-right: 0.3rem;
    }
  }

  .options {
    margin-top: 0.4rem;
    display: flex;
    flex-wrap: wrap;
    margin-left: 1rem;

    .option {
      margin-right: 1rem;

      b {
        margin-right: 0.3rem;
      }
    }
  }

  .desc {
    margin-top: 0.4rem;
    b {
      font-weight: 700;
    }
  }

  .opts {
    display: flex;
    justify-content: space-between;
    margin-top: 1rem;

    .labels {
      display: flex;
      line-height: 1;

      span {
        color: #999;
        display: inline-block;
        height: 20px;
        padding: 0 0.5rem;
        border-right: 1px solid #ccc;
      }

      span:first-of-type {
        padding-left: 0;
      }

      span:last-of-type {
        border: 0;
      }
    }

    .btn {
      height: 30px;
    }

    .btn-active {
      height: 30px;
      color: #fff;
    }
  }
}
</style>
